#include <CType.h>
#include <syslib.h>
#include <conio.h>
#include <string.h>

void getTime(int8_t * hr, int8_t * mn, int8_t * sc, int8_t *msc)
{
    int8_t h, m, s, ms;
    asm mov ah, 0x02;
    asm int 0x1A;

    asm mov h, ch;
    asm mov m, cl;
    asm mov s, dh;
    asm mov ms, dl;

    *hr = bcd2int(h);
    *mn = bcd2int(m);
    *sc = bcd2int(s);
    *msc = bcd2int(ms);

    return;
}

void getDate(int8_t * yr, int8_t * mn, int8_t * dy)
{
    int8_t y, m, d;
    asm mov ah, 0x04;
    asm int 0x1A;

    asm mov y, cl;
    asm mov m, dh;
    asm mov d, dl;

    *yr = bcd2int(y);
    *mn = bcd2int(m);
    *dy = bcd2int(d);

    return;
}

void displayDateTime(int8_t f)
{
    int8_t a, b, c, d;

    if (f & 1)
        {
        getDate(&a, &b, &c);

        printf("%d-%d-%d", a, b, c);
        }

    if (f == 3)
        printf(" ");

    if (f & 2)
        {
        getTime(&a, &b, &c, &d);

        printf("%d:%d:%d", a, b, c);
        }
    return;
}

void dosExit()
{
    asm mov ax,0x4c00;
    asm int 0x21;
    return;
}
